package com.itheima.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mapper.NursingLevelMapper;
import com.itheima.pojo.NursingLevel;
import com.itheima.pojo.PageResult;
import com.itheima.queryParams.NursingLevelParam;
import com.itheima.service.NursingLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingLevelServiceImpl extends ServiceImpl<NursingLevelMapper, NursingLevel> implements NursingLevelService {

    @Autowired
    private NursingLevelMapper nursingLevelMapper;

    @Override
    public PageResult queryAll(NursingLevelParam nursingLevelParam) {
        PageHelper.startPage(nursingLevelParam.getPage(),nursingLevelParam.getPageSize());
        List<NursingLevel> list = nursingLevelMapper.queryAll(nursingLevelParam);
        Page<NursingLevel> levelPage = (Page<NursingLevel>) list;
        return new PageResult(levelPage.getTotal(),levelPage.getResult());
    }
}
